package com.etennis.controller;

import com.etennis.pojos.ResponseResult;
import com.etennis.pojos.vo.app.MatchVO;
import com.etennis.pojos.vo.app.UserVO;
import com.etennis.service.IEventsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/app/match")
@Slf4j
@Api(tags = "用户端-赛事接口")
public class MatchController {
    @Autowired
    IEventsService iEventsService;

    @GetMapping
    @ApiOperation("可报名赛事信息")
    public ResponseResult<List<MatchVO>> matchList(){
        List<MatchVO> list=iEventsService.matchList();
        return ResponseResult.okResult(list);
    }

    @PostMapping("/signup/{id}")
    @ApiOperation("报名赛事")
    public ResponseResult signup(@PathVariable Long id){
        iEventsService.signup(id);
        return ResponseResult.okResult();
    }

    /**
     *
     * @return 赛事id、赛事name
     */
    @GetMapping("/registered")
    @ApiOperation("用户已报名赛事")
    public ResponseResult<List<MatchVO>> registered(){
        List<MatchVO> list=iEventsService.registeredMatch();
        return ResponseResult.okResult(list);
    }

    /**
     *
     * @param id 赛事id
     * @return 选手id，选手name
     */
    @GetMapping("/players/{id}")
    @ApiOperation("报名该赛事的选手")
    public ResponseResult<List<UserVO>> players(@PathVariable Long id){
        List<UserVO> list=iEventsService.registeredPlayers(id);
        return ResponseResult.okResult(list);
    }


}
